//
//  BaseNavigationController.m
//  guahao
//
//  Created by osx on 16/9/19.
//  Copyright © 2016年 osx. All rights reserved.
//

#import "BaseNavigationController.h"

@interface BaseNavigationController ()

@end

@implementation BaseNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //返回按钮
    //在push出一个控制器之前 设置导航控制器返回按钮的样式
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"product_button_back_nor.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(backButtonItemClick)];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    
    
    
}


+ (void)initialize {
    UINavigationBar *bar = [UINavigationBar appearance];
    //设置导航条背景
    [bar  setBackgroundImage:[UIImage imageNamed:@"nav"] forBarMetrics:UIBarMetricsDefault];
    //设置标题颜色
    bar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor blackColor]};
    //系统颜色
    bar.tintColor = [UIColor blackColor];
    
    
    
}
- (void)backButtonItemClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    [super pushViewController:viewController animated:animated];
    
    UIButton *btn = [[UIButton alloc] init];
    [btn setImage:[UIImage imageNamed:@"navback-2"] forState:UIControlStateNormal];
    [btn sizeToFit];
    [btn addTarget:self action:@selector(clickBackBtn) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    viewController.navigationItem.leftBarButtonItem = backItem;
    
    
    
}
- (void)clickBackBtn{
    [self popViewControllerAnimated:YES];
    
    
}






@end
